
""" log处理 """
from logging import DEBUG,INFO,ERROR,WARNING,CRITICAL,NOTSET, log
from loguru import logger as log

LOG_HISTORY_GLOBAL = []
CP8212_VOLTAGE_IDENT = "VOLTAGE "
def add_log(x1:str,level:str,ident:str):
    x1 = f"{ident}{x1}"
    if level == DEBUG or level == "10":
        log.debug(f"{x1}")
    elif level == ERROR or level == "40":
        log.error(f"{x1}")
    elif level == INFO or level == "10":
        log.info(f"{x1}")
    elif level == CRITICAL or level == "50":
        log.critical(f"{x1}")
    elif level == WARNING or level == "30":
        log.warning(f"{x1}")
    elif level == INFO or level == "25":
        log.success(f"{x1}")
    else:
        return False
    LOG_HISTORY_GLOBAL.append({"msg":x1,"level":level})
    return True